package com.myblog.mapper;

import com.myblog.entity.Blog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;


import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author From:星羽恒
 * @since 2021-11-24
 */
@Component  //自己写 sql  语句并需要在 test 测试时，加上 Component 注解，允许自动装配
public interface BlogMapper extends BaseMapper<Blog> {


    //@Select("SELECT * FROM t_blog AS a WHERE create_time = (SELECTE MAX(create_time) FROM t_blog AS b WHERE b.type_id = a.type_id)")
    @Select("SELECT * FROM t_blog AS a WHERE create_time = (SELECT MAX(create_time) FROM t_blog AS b WHERE b.type_id = a.type_id)")
    List<Blog> getTopOfGroup();
}
